public class Main {

    public static class Login{
        private String UserName = "jack256";
        private String Password = "123456";
        public void loginInfo (String username,String password) throws UserNameException,PasswordException{
            if(!this.UserName.equals(username)){
                //System.out.println("用户名错误！");
                throw new UserNameException("用户名错误！");
            }
            if(!this.Password.equals(password)){
                //System.out.println("密码错误！");
                throw new PasswordException("密码错误！");
            }
            System.out.println("登录成功！");
        }
    }
    public static void Main(String[] args)throws UserNameException,PasswordException {
        Login login = new Login();
        try {
            login.loginInfo("jack256","123456");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("UserNameException");
        }catch (PasswordException e){
            e.printStackTrace();
            System.out.println("PasswordException");
        }
    }
}